package cn.dogger.easyboot.login.service.impl;

import cn.dogger.easyboot.system.domain.entity.SysUser;
import cn.dogger.easyboot.system.domain.enums.SysUserStatus;
import cn.dogger.easyboot.system.mapper.SysUserMapper;
import cn.dogger.easyboot.login.service.LoginService;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import org.springframework.stereotype.Service;

/**
 * @author dogger
 * 2022/4/17 14:56
 */
@Service
public class LoginServiceImpl implements LoginService {

    private final SysUserMapper sysUserMapper;

    public LoginServiceImpl(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }

    @Override
    public SysUser doLogin(String userName, String password, String verificationCode) {
        return new LambdaQueryChainWrapper<>(sysUserMapper)
                .eq(SysUser::getUserName, userName)
                .eq(SysUser::getStatus, SysUserStatus.VALID.getCode())
                .one();
    }
}
